package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.baidu.BaiduAiUtils;
import com.ruoyi.system.service.FaceLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FaceLoginServiceImpl implements FaceLoginService {

    @Autowired
    private BaiduAiUtils baiduAiUtils;

    @Override
    public boolean registerFace(Long userId, String image) {
        // 处理base64编码内容
        String imageData = image.substring(image.indexOf(",") + 1);
        return baiduAiUtils.faceRegister(userId.toString(), imageData);
    }

    @Override
    public String loginByFace(String image) {
        // 处理base64编码内容
        String imageData = image.substring(image.indexOf(",") + 1);
        return baiduAiUtils.faceSearch(imageData);
    }
}